package com.ele.Servlet;

import com.ele.Pojo.Employee;
import com.ele.Service.impl.EmployeeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/add")
public class AddEmpServlet extends HttpServlet {
    //创建Service对象
    EmployeeServiceImpl employeeService =new EmployeeServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //告诉服务器格式
        req.setCharacterEncoding("utf-8");
        String account=req.getParameter("account");
        String telephone=req.getParameter("telephone");
        String nickname=req.getParameter("nickname");
        String password=req.getParameter("password");
        String role=req.getParameter("role");
        String is_del =req.getParameter("isDel");
//        System.out.println("昵称"+nickname);
//        System.out.println("昵称"+is_del);
        Employee emp =new Employee();
        emp.setAccount(account);
        emp.setTelephone(telephone);
        emp.setNickname(nickname);
        emp.setPassword(password);
        emp.setRole(role);
        emp.setIsDel(Integer.valueOf(is_del));
        int x=employeeService.addEmp(emp);
        resp.getWriter().write(x+"");

    }

}
